package com.wutuo.wtservice.provider.dao;

import cn.apestar.core.base.GenericMapper;
import cn.apestar.core.base.MapperAnnotation;
import com.wutuo.wtservice.provider.domain.WtUserService;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * 服务关系表 Dao 层
 *
 * @author lvh
 * @version 1.0
 */

@MapperAnnotation public interface BaseUserServiceMapper
    extends GenericMapper<WtUserService, Long> {

    @Override @Delete({"delete from user_service", "where id = #{id,jdbcType=BIGINT}"})
    int deleteByPrimaryKey(Long id);

    @Override @Insert({"insert into user_service (", "wt_service_id,", "roster_id,", "create_by,",
        "create_date,", "update_by,", "update_date,", "remarks,", "del_flag", " )values(",
        "#{wtServiceId,jdbcType=BIGINT},", "#{rosterId,jdbcType=BIGINT},",
        "#{createBy,jdbcType=BIGINT},", "#{createDate,jdbcType=DATE},",
        "#{updateBy,jdbcType=BIGINT},", "#{updateDate,jdbcType=DATE},",
        "#{remarks,jdbcType=VARCHAR},", "#{delFlag,jdbcType=VARCHAR})"}) int insert(
        WtUserService record);

    @InsertProvider(type = BaseUserServiceSqlProvider.class, method = "insertSelective")
    int insertSelective(WtUserService record);

    @Override
    @Select({"select", "wt_service_id,", "roster_id,", "create_by,", "create_date,", "update_by,",
        "update_date,", "remarks,", "del_flag", "from user_service",
        "where id = #{id,jdbcType=BIGINT}"})
    @Results({@Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
        @Result(column = "wt_service_id", property = "wtServiceId", jdbcType = JdbcType.BIGINT),
        @Result(column = "roster_id", property = "rosterId", jdbcType = JdbcType.BIGINT),
        @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.BIGINT),
        @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.DATE),
        @Result(column = "update_by", property = "updateBy", jdbcType = JdbcType.BIGINT),
        @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.DATE),
        @Result(column = "remarks", property = "remarks", jdbcType = JdbcType.VARCHAR),
        @Result(column = "del_flag", property = "delFlag", jdbcType = JdbcType.VARCHAR)})
    WtUserService selectByPrimaryKey(Long id);

    @Override
    @UpdateProvider(type = BaseUserServiceSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(WtUserService record);

    @Override
    @Update({"update user_service", "set ", "wt_service_id = #{wtServiceId,jdbcType=BIGINT},",
        "roster_id = #{rosterId,jdbcType=BIGINT},", "create_by = #{createBy,jdbcType=BIGINT},",
        "create_date = #{createDate,jdbcType=DATE},", "update_by = #{updateBy,jdbcType=BIGINT},",
        "update_date = #{updateDate,jdbcType=DATE},", "remarks = #{remarks,jdbcType=VARCHAR},",
        "del_flag = #{delFlag,jdbcType=VARCHAR}", "where id = #{id,jdbcType=BIGINT}"})
    int updateByPrimaryKey(WtUserService record);
}